const db = require('../utils/db');

module.exports = {
    /**
     * 添加交易记录
     */
    async addTradeRecord(formData) {
        let res = await db.insert('trade_record', formData);
        return res;
    },
    /**
     * 获取出售记录
     */
    async getSaleRecord(formData) {
        let sql = `
        SELECT book_id FROM trade_record
        WHERE seller_id = '${formData.user}'
       `;
        let res = await db.query(sql);
        return res;
    },
    /**
     * 获取购买记录
     */
    async getPurchaseRecord(formData) {
        let sql = `
        SELECT book_id FROM trade_record
        WHERE buyer_id = '${formData.user}'
       `;
        let res = await db.query(sql);
        return res;
    }

    
}